package com.vincent.cloudhystrix;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class ClientService {

    @Autowired
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "showError")
    public String reqClientService() {
        return restTemplate.getForObject("http://cloud-eureka-client/", String.class);
    }

    public String showError() {
        return "hi,sorry,error!";
    }

}
